package com.s2u2m.training.ex_programmer.single_responsibility.good;

import com.s2u2m.training.ex_programmer.single_responsibility.Item;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;


class ShoppingCart {
    private List<Item> items = new LinkedList<>();

    public void addItem(Item item) {
        items.add(item);
    }

    public BigDecimal getTotalPrice() {
        BigDecimal total = BigDecimal.ZERO;
        for (Item item : items) {
            total = total.add(item.getPrice());
        }
        return total;
    }

    public List<Item> getItems() {
        return Collections.unmodifiableList(items);
    }
}
